
$(function (){
   if($.trim($("#username").val()).length<1) {
      $("#username").focus();
   }else {
      $("#password").focus();
   }
});

function enterIn(evt){
   var evt=evt?evt:(window.event?window.event:null);
   if (evt.keyCode==13){
      submitForm();
   }
 }

function submitForm() {
	var username = $("#username").val();
	var password = $("#password").val();
	if($.trim(username).length<1) {
		alert("用户名不能为空！");
		$("#username").focus();
	}else if($.trim(password).length<1) {
		alert("密码不能为空！");
		$("#password").focus();
	}else {
		$.ajax({
			url : 'login!loginSystem.action',
			type : 'post',
			data: {
				"username": username,
				"password": $.md5(password)
			},
			dataType: 'html',
			success : function(data) {
				Interceptor(data);
			     if(data!=null && data.indexOf(".jsp")==-1) {
			    	 alert(data);
			     }else{
					document.location.href = data;
				 }
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				// 保存失败
				alert('error:' + textStatus);
			}
	  });
	}
}